package day_2022_7_to_8.day48;

/**
 * @author haomin
 * @date 2022/08/28 23:06
 **/
public class Day43_8_Num50_MyPow {
    class Solution {
        public double myPow(double x, int n) {
            double res = 1.0;
            for(int i = n; i != 0; i /= 2){
                if(i % 2 != 0){
                    res *= x;
                }
                x *= x;
            }
            return n < 0 ? 1/res : res;
        }
    }
}